/**
 * $Id$
 * @author mcanovas
 * @date   Feb 29, 2012 2:47:26 PM
 *
 * Copyright (C) 2012 Scytl Secure Electronic Voting SA
 *
 * All rights reserved.
 *
 */
package org.sk.gsync.app.mybatis;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface FolderMapper {

    @Update("CREATE TABLE IF NOT EXISTS FOLDER (PATH VARCHAR2(255) PRIMARY KEY)")
    void createTable();

    @Select("SELECT * FROM FOLDER")
    List<Folder> getAll();

    @Select("SELECT COUNT(*) FROM FOLDER F WHERE F.PATH = #{path}")
    int exists(@Param("path") String path);

    @Insert("INSERT INTO FOLDER VALUES(#{folder.path})")
    void insert(@Param("folder") Folder folder);

    @Delete("DELETE FROM FOLDER F WHERE F.PATH = #{folder.path}")
    void delete(@Param("folder") Folder folder);

}
